home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
PET
/
S-Super PET
/
(s)tl.d64
/
NSCROLL.ASM
< prev
next >
Wrap
Assembly Source File
|
2009-01-18
|
6KB
|
224 lines
; 'nscroll' -- reconstructed from binary by T.M. Peterson
; 6/19/83
; Altered 7/01/83 for better print & serial buffering
; " 7/06/83 for warm start after accid. lang. exit
; " 7/10/83 for STOP during RVS pause
; Rewritten as required to be completely relocatable without re-assembly
xdef byt_get ;routine to hand byte to BASIC/??
xref TGetCurs_,Openf_,Closef_,FPutRec_,FPutNL_,Printf_
byt_buf equ $FF ;put rcv'd byte here on request
begin equ * ;setup IRQ vector
leax scrol,pc ;get new vector
cmpx $0108 ;test current vector
if ne ;not already changed
ldd $0108 ;get old
STD oldvec,pc ;save it
STX $0108 ;alter current vector
endif
dex
stx $22 ;keep from over-writing
leax beg_buf,pc ;init. buffer pointers
stx i_ptr,pc
stx o_ptr,pc
leax hello,pc
tfr x,d
leax byt_get,pc
pshs x
jsr printf_
leas 2,s
CLR $32 ;flag done
RTS
hello fcc "NScroll -- Version 8/28/83"
fcb $D
fcc "Now Activated."
fcb $D,$D
fcc "(Test for buffered char. from 'serial' with 'sys %d'.)"
fcb $D,0
scrol LDD $012e ;save keybuf index
PSHS d
lda $EFF1 ;did ACIA call us?
if mi ;(yes)
anda buf_nable,pc ;have Rxd?
if ne ;(yes)
lbsr buf_byt ;go put in buffer
endif
else
JSR [oldvec,pc] ;go do 1st lev. IRQ
BSR tstRVSky
BEQ scro9 ;not RVS
TST busyflg,pc ;already handling?
BNE scro9 ;yes, never mind
DEC busyflg,pc ;flag busy
LDX ,S ;retr. kybf indx
LDA #$ff ;test last keystroke
CMPA ,X ;was it RVS?
if eq
STX $012e ;undo RVS keystroke
endif
BSR keytst ;test for halt/print
CLR busyflg,pc ;not busy anymore
endif
scro9 LEAS 2,S ;clr stack
RTS
keytst BSR tstSHFT ;shift key dn?
if ne ; NE ==> yes
BSR openfl ;go do dump
endif
BSR tstRVSky ;RVS still dn?
BNE keytst ;yes, loop
loop
bsr tstSTOP ;Test for STOP
if ne ;Yes, but
bsr tstSHFT ;is it really RUN?
if ne ;Yes, do warm start
leas 2,s ;Dump RTS addrs.
clr busyflg,pc
jmp [$10C] ;Treat like NMI
else
rts ;no, do STOP
endif
endif
BSR tstRVSky ;wait for 2nd RVS
until ne
BSR tstSHFT
BNE keytst ;shifted--do dump
loop
BSR tstRVSky ;wait for not RVS
until eq
RTS
; Test for STOP key: row 9, bit 4
; CC(Z)=1 if not stop
tstSTOP ldd #$910
bra tstIT
; Since RVS key clears b0 of row 8,
; test it. RTS with CC(Z)=1 if NOT RVS.
tstRVSky ldd #$801 ;select row 8, bit 0
bra tstIT
; Ditto for SHIFT keys. CC(Z)=1 if
; neither key is down.
tstSHFT ldd #$641 ;sel. row 6, bits 6&0
tstIT pshs b
sei
STA $e810 ;sel. row
andb $e812 ;mask bit(s)
cli
cmpb ,s ;all set?
leas 1,s ;clr stk
RTS ;Z=1 means bit(s) set
fltype fcc "W"
fcb 0
flname fcc "ieee4" ; substitute 'printer' or 'serial' as needed
fcb 00,00,00
openfl leax fltype,pc
pshs x
leax flname,pc
tfr x,d
JSR Openf_ ;go open it
LEAS 2,S
BNE prnt ;open successful
RTS
prnt LEAS -4,S ;res some stack space
STD $02,S ;save cntrl blk
JSR FPutNL_
LDX #$8000 ;start at CRT beg.
prnt1 STX ,S ;save pntr
LDB #79 ;max 80 chars/line
LDA #$20 ;space
loop
CMPA B,X ;look for eol
quif ne ;here it is
DECB ;to beg. of line?
until mi
CLRA
INCB ;adj. count
PSHS d
PSHS x
LDD $06,S ;get cntrl blk ptr
JSR FPutRec_ ;print#P1, (P2).(P3)
LEAS 4,S ;clean stack
bsr tstSTOP ;test for STOP
bne prnt2
LDX ,S ;get pntr back
LEAX 80,X ;bump to nxt line
tfr x,d ;make copy
anda #$7f ;strip CRT offset
cmpd $122 ;back to crsr?
blo prnt1 ;no, loop
prnt2 LDD $02,S ;close file
JSR Closef_
LEAS 4,S ;release stk space
RTS
buf_byt equ * ;buffer rec'd data
lda $EFF0 ;get byte
ldx i_ptr,pc
sta ,x+
bsr end_chk ;chk for over-run
stx i_ptr,pc
rts
; The following byte is used to turn on/off the 'serial' buffering
; facility. You might wish to turn it off while in 'passthru' for
; example. When nscroll is booted the buffer is ON.
; N.B.: buf_nable = byt_get - 1 (Addrs. of byt_get printed at boot-up)
buf_nable fcb 8 ;'8'= buffer enabled, '0'= disabled.
byt_get equ * ;fetch byte from buffer
clr byt_buf-1 ;preset no-byte
ldx o_ptr,pc
cmpx i_ptr,pc
if ne
inc byt_buf-1 ;flg byte pres.
lda ,x+ ;get byte, put
sta byt_buf ;where BASIC can find
bsr end_chk ;over-run buffer?
stx o_ptr,pc ;update ptr.
endif
rts
end_chk equ *
cmpx #end_buf ;over-run buffer?
if eq ;yes, reset
leax beg_buf,pc
endif
rts
i_ptr rmb 2
o_ptr rmb 2
busyflg fcb 0
oldvec rmb 2
beg_buf equ * ;use here to CRT for buffer
end_buf equ $7FFF
end